project(ksvgeditor_core)

set(CMAKE_AUTOMOC ON)

find_package(Qt5 REQUIRED COMPONENTS Widgets Network Core Gui Xml)

# Shape Types
set(SHAPE_HEADER_FILES
    kshapetype.h
    kshape.h
    krectshape.h
    kellipseshape.h
    kmouseshape.h
    kshapefactory.h
    kexportshape.h
    kfreehandshape.h
    klineshape.h
    kstarshape.h
    ktextshape.h
    kpentagonshape.h
    krhombusshape.h
    kcloudshape.h
    khexagonshape.h
    kheartshape.h
)
set(SHAPE_CPP_FILES
    kshape.cpp
    krectshape.cpp
    kellipseshape.cpp
    kmouseshape.cpp
    kshapefactory.cpp
    kexportshape.cpp
    kfreehandshape.cpp
    klineshape.cpp
    kstarshape.cpp
    ktextshape.cpp
    kpentagonshape.cpp
    krhombusshape.cpp
    kcloudshape.cpp
    khexagonshape.cpp
    kheartshape.cpp
)

# JSON Reading
set(JSON_HEADER_FILES
    kjsonread.h
    kexportjsonread.h
)
set(JSON_CPP_FILES
    kjsonread.cpp
    kexportjsonread.cpp
)

set(HEADER_FILES
    ${SHAPE_HEADER_FILES}
    ${JSON_HEADER_FILES}
)

set(CPP_FILES
    ${SHAPE_CPP_FILES}
    ${JSON_CPP_FILES}
)

set(UI_FILES
)

set(RCC_FILES
)

source_group("Shape Files" FILES ${SHAPE_HEADER_FILES} ${SHAPE_CPP_FILES})
source_group("JSON Read" FILES ${JSON_HEADER_FILES} ${JSON_CPP_FILES})
source_group("Form Files" FILES ${UI_FILES})
source_group("Resource Files" FILES ${RCC_FILES})

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${CPP_FILES} ${UI_FILES} ${RCC_FILES})

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E make_directory
        ${CMAKE_BINARY_DIR}/bin/$<CONFIG>
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        $<TARGET_FILE:${PROJECT_NAME}>
        ${CMAKE_BINARY_DIR}/bin/$<CONFIG>
)

target_include_directories(${PROJECT_NAME} PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
)

target_compile_definitions(${PROJECT_NAME} PRIVATE KSHAPE_DLL KJOSNREAD_DLL)

target_link_libraries(${PROJECT_NAME} PUBLIC
    Qt5::Widgets
    Qt5::Gui
    Qt5::Core
    Qt5::Network
    Qt5::Xml
)